$(function () {
    //短信验证码
    $('.sendVerifyCode').on('click', function () {
        
        //获取手机号
        let mobile = $('input[name="mobile"]').val();
        
        let time = 9;
        $.get(baseUrl+'/user/sendVerify',{mobile},function(res){
            console.log(res);
            if(res.code !=0){
               alert(res.msg);
                return;
            }
            let timer = setInterval(function () {
                time--
                if (time == 0) {
                    clearInterval(timer)
                    $('.sendVerifyCode').text('获取验证码').removeClass('layui-btn-disabled')
                    return false;
                } else {
                    $('.sendVerifyCode').text(time + 's再次获取验证码').addClass(' layui-btn-disabled')
                }
    
            }, 1000)
        })
        
      
    })

    //注册
    $('.login_btn').on('click',function(){
        let data =$('.login_form form').serialize();
        console.log(data);
        $.post(baseUrl+'/user/register',data,function(res){
            if(res.code !=0){
                alert(res.msg)
                return false;
            }
            location.href='login.html'
        })
        return false;
    })
});